package com.scorpio.utils;

import com.alibaba.fastjson.JSONObject;
import com.scorpio.common.utils.ServletUtils;
import com.scorpio.common.utils.StringUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

public class AppUtils {

    /**
     * 获取登录用户设备信息
     *
     * @return
     */
    public static DeviceVo getUserDeviceInfo() {
        HttpServletRequest request = ServletUtils.getRequest();
        Enumeration<String> names = request.getHeaderNames();
        JSONObject json = new JSONObject();
        while (names.hasMoreElements()) {
            String key = names.nextElement();
            json.put(key, request.getHeader(key));
        }
        DeviceVo vo = json.toJavaObject(DeviceVo.class);
        return vo;
    }
}
